<!-- 常用流程-发起会堪 -->
<template>
  <div style="width: 100%; height: calc(100% - 32px)">
    <div class="points-config-page">
      <div class="mb-[24px]">
        <px-button type="primary" icon="ArrowLeft" @click="backDetailPage">返回</px-button>
      </div>
      <iframe v-if="!loading" class="points-config-iframe" width="100%" name="SystemProcessWorkBench" frameborder="0" :src="url" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { getToken } from "@/utils/auth";
import { queryTemplateInfo } from "@/api/point";
defineOptions({
  name: "SystemProcessWorkBenchConfig"
});
const wuToken = getToken().accessToken || ""; // 用户登录token
const { VITE_FFP_URL } = import.meta.env; //ffp页面url
const url = ref();
const loading = ref(true);
const init = async () => {
  // 1、获取会堪模板信息
  const info: any = await queryTemplateInfo(wuToken);
  // 2、获取用户信息
  const userInfo = JSON.parse(localStorage.getItem("userInfo"));
  // 3、iframe连接
  url.value = `${VITE_FFP_URL}/?ssoToken=${wuToken}&isHiddenMenu=true&language=zh-cn#/workbench/config/${info.id}?tempVersionId=${info.tempVersionId}&id=${info.id}&flowName=${info.flowName}&skipType=InitiateFlow&initiateFlowSpnsor=${userInfo.username}&pageName=config`;
  // 4、显示页面
  loading.value = false;
};
const router = useRouter();
const route = useRoute();
// 跳转到返回列表页
const backDetailPage = () => {
  const {
    query: { id }
  } = route;
  router.push({ path: "/all/progress/fsim/my", query: { id } });
};
onMounted(() => {
  init();
});
</script>
<style lang="scss" scoped>
.points-config-page {
  height: 100%;
  padding: 24px;
  background-color: #fff;
  border-radius: 8px;
  .points-config-iframe {
    height: calc(100% - 56px);
  }
}
</style>
